<?php
/**
* @version		$Id: browser.php 36 2011-01-20 12:59:29Z happy_noodle_boy $
* @package      JCE
* @copyright    Copyright (C) 2005 - 2009 Ryan Demmer. All rights reserved.
* @author		Ryan Demmer
* @license      GNU/GPL
* JCE is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
*/
// no direct access
defined('_JEXEC') or die('ERROR_403');

class WFAggregatorExtension extends WFExtension 
{
	/*
	*  @var varchar
	*/
	var $extensions = array();
	/**
	* Constructor activating the default information of the class
	*
	* @access	protected
	*/
	function __construct()
	{
		parent::__construct();
	}
	/**
	 * Returns a reference to a plugin object
	 *
	 * This method must be invoked as:
	 * 		<pre>  $advlink = &AdvLink::getInstance();</pre>
	 *
	 * @access	public
	 * @return	JCE  The editor object.
	 * @since	1.5
	 */
	function &getInstance()
	{
		static $instance;

		if (!is_object($instance)) {
			$instance = new WFAggregatorExtension();
		}
		
		return $instance;
	}
	
	function display($type)
	{
		parent::display();
		
		$document =& WFDocument::getInstance();
		
		 // Load javascript    
        $document->addScript(array(
            'extensions/aggregator'
        ), 'libraries');
        
        $aggregator =& $this->getAggregator($type);
        $aggregator->display();
	}
	
	function &getAggregator($type)
	{
		static $aggregators;

		if (!isset($aggregators)) {
			$aggregators = array();
		}

		if (empty($aggregators[$type])){
			// load aggregator class
			wfimport('editor.extensions.aggregator.' . $type);
			
			$classname 	= 'WF'.ucfirst($type).'Aggregator';
			$aggregators[$type] = new $classname();
		}

		return $aggregators[$type];
	}
}